home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / cron.daily / standard < prev   
Encoding:
Text File  |  2010-12-18  |  3.5 KB  |  135 lines

  1. #!/bin/sh
  2. # /etc/cron.daily/standard: standard daily maintenance script
  3. # Written by Ian A. Murdock <imurdock@gnu.ai.mit.edu>
  4. # Modified by Ian Jackson <ijackson@nyx.cs.du.edu>
  5. # Modified by Steve Greenland <stevegr@debian.org>
  6.  
  7. # Start in the root filesystem, make SElinux happy
  8. cd /
  9. bak=/var/backups
  10. LOCKFILE=/var/lock/cron.daily
  11. umask 022
  12.  
  13. #
  14. # Avoid running more than one at a time 
  15. #
  16.  
  17. if [ -x /usr/bin/lockfile-create ] ; then
  18.     lockfile-create $LOCKFILE
  19.     if [ $? -ne 0 ] ; then
  20.     cat <<EOF
  21.  
  22. Unable to run /etc/cron.daily/standard because lockfile $LOCKFILE
  23. acquisition failed. This probably means that the previous day's
  24. instance is still running. Please check and correct if necessary.
  25.  
  26. EOF
  27.     exit 1
  28.     fi
  29.  
  30.     # Keep lockfile fresh
  31.     lockfile-touch $LOCKFILE &
  32.     LOCKTOUCHPID="$!"
  33. fi
  34.  
  35. #
  36. # Backup key system files
  37. #
  38.  
  39. if cd $bak ; then
  40.     cmp -s passwd.bak /etc/passwd || (cp -p /etc/passwd passwd.bak &&
  41.                       chmod 600 passwd.bak)
  42.     cmp -s group.bak /etc/group || (cp -p /etc/group group.bak &&
  43.                     chmod 600 group.bak)
  44.         if [ -f /etc/shadow ] ; then
  45.       cmp -s shadow.bak /etc/shadow || (cp -p /etc/shadow shadow.bak &&
  46.                                             chmod 600 shadow.bak)
  47.     fi
  48.         if [ -f /etc/gshadow ] ; then
  49.       cmp -s gshadow.bak /etc/gshadow || (cp -p /etc/gshadow gshadow.bak &&
  50.                           chmod 600 gshadow.bak)
  51.     fi
  52. fi
  53.  
  54. #
  55. # Check to see if any files are in lost+found directories and warn admin
  56. #
  57. # Get a list of the (potential) ext2, ext3, ext4 and xfs l+f directories
  58. # Discard errors, for systems not using any of these.
  59. lfdirs=`df -P --type=ext2 --type=ext3 --type=ext4 --type=xfs 2>/dev/null |
  60.     awk '/\/dev\// { print }' | sed -e 's/ [[:space:]]*/ /g'  |
  61.     while read mount block used avail perc mp; do
  62.         [ "$mp" = "/" ] && mp=""
  63.         echo "$mp/lost+found"
  64.     done`
  65.  
  66. # Don't use space as a field separator
  67. oldifs="$IFS"
  68. IFS=`printf '\n\t'`
  69.  
  70. for lfdir in $lfdirs; do
  71. # In each directory, look for files
  72.     if [ -d "$lfdir" ] ; then
  73.     more_lost_found=`ls -1  "$lfdir" 2>/dev/null | grep -v 'lost+found$' | sed 's/^/    /'`
  74.     if [ -n "$more_lost_found" ] ; then
  75.         lost_found="$lost_found
  76.  
  77. $lfdir:
  78. $more_lost_found"
  79.         # NOTE: above weird line breaks in string are intentional!
  80.         fi
  81.     else
  82. # Do nothing for XFS filesystems they do not need to
  83. # have a lost and found dir
  84.         fs=`cat /proc/mounts | grep " ${lfdir%/lost+found} "`
  85.         case "$fs" in
  86.             ext*)
  87.             no_lost_found="$no_lost_found
  88. $lfdir"
  89.                 ;;
  90.             *)
  91.                 ;;
  92.         esac
  93.     fi
  94. done
  95.  
  96. # Restore IFS
  97. IFS="$oldifs"
  98. unset oldifs
  99.  
  100. # NOTE: This might need to be configurable if systems abound
  101. # w/o lost+found out there to prevent giving out this warning
  102. # every day.
  103. if [ -n "$lost_found" ]; then
  104.     cat << EOF
  105. Files were found in lost+found directories. This is probably
  106. the result of a crash or bad shutdown, or possibly of a disk
  107. problem. These files may contain important information. You
  108. should examine them, and move them out of lost+found or delete
  109. them if they are not important.
  110.  
  111. The following files were found:
  112. $lost_found
  113. EOF
  114. fi
  115.  
  116. if [ -n "$no_lost_found" ]; then
  117.     cat << EOF
  118. Some local filesystems do not have lost+found directories. This
  119. means that these filesystems will not be able to recover
  120. lost files when the filesystem is checked after a crash.
  121. Consider creating a lost+found directory with mklost+found(8).
  122.  
  123. The following lost+found directories were not available:
  124. $no_lost_found
  125. EOF
  126. fi
  127.  
  128. #
  129. # Clean up lockfile
  130. #
  131. if [ -x /usr/bin/lockfile-create ] ; then
  132.     kill $LOCKTOUCHPID
  133.     lockfile-remove $LOCKFILE
  134. fi
  135.